<?php
defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' );
/**
 * @author chaituan@126.com
 */
use EasyWeChat\Foundation\Application;
class C extends CI_Controller {

	function index() {
			redirect('http://www.chaituans.com');exit;
			$forward = base_url('/mobile/c/login/');
			$config = array('app_id'=>'wxabe1966e9c3e071d','secret'=>'00667eb903b74042edbf91abeacf293a','oauth' => ['scopes'=> ['snsapi_userinfo'],'callback' => $forward]);
			$app = new Application($config);
			$response = $app->oauth->scopes(['snsapi_userinfo'])->redirect();			
			$response->send();
			die();
	}
	
	function login(){
		//获取授权登录的微信用户信息
		$app = new Application(array('app_id'=>'wxabe1966e9c3e071d','secret'=>'00667eb903b74042edbf91abeacf293a'));
		$user = $app->oauth->user()->toArray();
		echo '您的OPENID是：<br> <h2>'.$user['id'].'</h2>';
		exit();
	}

}
